package collection.set;

import java.util.HashSet;
import java.util.Iterator;

public class HashSetExample {
	HashSet<String> hset;
	
	public HashSetExample() {
		hset = new HashSet<String>();
		addData();
	}
	
	public void addData(){
		hset.add("hello");
		hset.add("bonjour");
		hset.add("bonjour");
		hset.add("Xin chao");
		hset.add("xin Chao");
	}
	
	public void display(){
		Iterator<String> iter = hset.iterator();
		while (iter.hasNext()){
			System.out.println(iter.next());
		}
		
		System.out.println();
		System.out.println("hset union hset: ");
		addSet(hset);
		
		iter = hset.iterator();
		while (iter.hasNext()){
			System.out.println(iter.next());
		}
	}
	
	public void addSet(HashSet<String> set){
		hset.addAll(set);
	}
	
	public static void main(String[] args) {
		new HashSetExample().display();
	}
}
